#pragma once
#include "WeaponSystems.h"
#include "Thruster.h"
#include "ParticleSystem.h"

#define WARP_SPEED 1000

class BasicShip : public BaseIndexedGraphicalEntity
{
protected:
	std::vector<BasicThruster*> Thrusters;
	std::vector<short> ThrusterThrottle;

	bool EnterWarp,IsWarping,ExitWarp;
	bool CanToggleWarp;
	float LastWarp;
	
	D3DXVECTOR3 Angles;

public:
	PhysicsBox BoundingBox;

	BasicShip();
	BasicShip(IDirect3DDevice9 *nDevice);

	virtual ~BasicShip( void );

	virtual void InitThrusters( float nThrust ) = 0;

	void SetPosition( D3DXVECTOR3 nPosition );
	void SetVelocity( D3DXVECTOR3 nVelocity );

	virtual void Update( float dt );
	virtual void Render( void );

	D3DXVECTOR3 GetAngles( void );

	void SetAngles(D3DXVECTOR3 nAngles);
	void SetAngles(float nX, float nY, float nZ);

	void ToggleWarp( void );
	bool GetIsWarping( void );
	bool GetEnterWarping( void );
	bool GetExitWarping( void );
};

class TestShip : public BasicShip
{
private:
	D3DXMATRIX TransMat;
	D3DXMATRIX WVPMat;
	ID3DXEffect *Effect;

	D3DXMATRIX RotationMatrix;

	float Thrust;
	float Mass;

	Explosion *DeathExplosion;

	bool isDying;
	float DeathTime;

public:
	TestShip();
	TestShip(IDirect3DDevice9 *nDevice, float nMass, D3DXVECTOR3 ShipSize);
	~TestShip();

	virtual void InitThrusters( float nThrust );

	virtual void Update( float dt );
	virtual void Render( void );

	void SetEffect(ID3DXEffect *nEffect);
	void SetWVPMat(D3DXMATRIX nWVP);

	void SetForwardThrottle(short nThrottle);
	void SetBackwardThrottle(short nThrottle);
	void SetLeftThrottle(short nThrottle);
	void SetRightThrottle(short nThrottle);

	void SetEyePosition(const D3DXVECTOR3 &nVector);
	short GetThrottle( void );

	bool GetIsDying( void );

	void KillMe( void );
	void Reset( void );
};
